Skip to content

Fix: Handle missing config file gracefully#52

Open
xyaz1313 wants to merge 1 commit intoApexOpsStudio:mainfrom
xyaz1313:fix/missing-config-crash
Open

Fix: Handle missing config file gracefully#52
xyaz1313 wants to merge 1 commit intoApexOpsStudio:mainfrom
xyaz1313:fix/missing-config-crash

Conversation

@xyaz1313
Copy link
Copy Markdown

Summary

Fixes #2 — the app no longer crashes with FileNotFoundError when ~/.config/task-cli/config.yaml is missing.

Changes

task.py

  • Added DEFAULT_CONFIG constant with sensible default values
  • Updated load_config() to:
    • Check if config file exists before attempting to read
    • Create the config directory (~/.config/task-cli/) if it doesn't exist
    • Write a default config file automatically
    • Return default config values on first run

test_task.py

  • Added test_load_config_missing_file that verifies:
    • No crash when config file is missing
    • Default config is created with expected content
    • Subsequent loads return the same content

.gitignore

  • Added __pycache__/ and *.pyc to prevent Python bytecode from being committed

Testing

All tests pass:

test_task.py::test_validate_description PASSED
test_task.py::test_validate_task_id PASSED
test_task.py::test_load_config_missing_file PASSED

Acceptance Criteria

  • No crash when config file is missing
  • Creates sensible default config automatically
  • Tests added for missing config scenario
  • Documentation (default config) is self-explanatory

Previously, load_config() would crash with FileNotFoundError when
~/.config/task-cli/config.yaml didn't exist.

Now it:
- Creates the config directory if missing
- Writes a sensible default config file
- Returns default config values

Added test_load_config_missing_file to verify the fix.

Fixes ApexOpsStudio#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Crash when config file missing

1 participant